#include "Scan.h"

Scan::Scan(unsigned int maxElements) {
    // Allocate temporary storage
    initialize(maxElements);
}

Scan::~Scan() {
}

void Scan::initialize(unsigned int numElements) {

    // Initialize scan
    CUDPPConfiguration scanConfig;
    scanConfig.algorithm = CUDPP_SCAN;
    scanConfig.datatype = CUDPP_UINT;
    scanConfig.op = CUDPP_ADD;
    scanConfig.options = CUDPP_OPTION_EXCLUSIVE | CUDPP_OPTION_FORWARD;
    cudppPlan(&mScanPlan, scanConfig, numElements, 1, 0);
}

void Scan::CriaOffset(unsigned int* countDevice, unsigned int* offSetDevice, unsigned int  numElements){
    cudppScan(mScanPlan, offSetDevice, countDevice, numElements);
}